package com.mondo.financialwallet.presentation.ui.fragment;

import android.app.Activity;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.example.common.ui.BaseFragment;
import com.mondo.financialwallet.R;
import com.mondo.financialwallet.presentation.ui.activity.FinancialOrderListActivity;
import com.mondo.financialwallet.presentation.ui.adapter.SimpleFragmentPagerAdapter;
import com.mondo.financialwallet.presentation.utils.ActivityTitleBarHelper;
import com.mondo.financialwallet.presentation.utils.adapter.BaseOnTabSelectedListenerAdapter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;

/**
 * 理财
 */
public class FinancialFragment extends BaseFragment {

    @Bind(R.id.history_order_image) View mHistoryOrderImage;
    @Bind(R.id.financial_tab_layout) TabLayout mFinancialTabLayout;
    @Bind(R.id.financial_view_pager) ViewPager mFinancialViewPager;

    public static Fragment newInstance() {
        return new FinancialFragment();
    }

    @Override
    protected void setStatusBar(Activity activity) {
        ActivityTitleBarHelper.setTransparentDarkColorStatus(activity);
    }

    @Override
    protected int getLayoutID() {
        return R.layout.fragment_financial;
    }

    @Override
    protected void initActions() {
        // 历史订单
        mHistoryOrderImage.setOnClickListener(v ->
                FinancialOrderListActivity.launch(v.getContext()));

        // 理财产品、持有产品
        mFinancialTabLayout.setupWithViewPager(mFinancialViewPager);
        mFinancialViewPager.setAdapter(new SimpleFragmentPagerAdapter(
                getFragmentManager(),
                Arrays.asList(getString(R.string.tab_market), getString(R.string.tab_hold)),
                Arrays.asList(new FinancialProductFragment(), new HoldProductFragment()))
        );
    }
}
